/*
 * @Author: 余保林 yubaolin6@outlook.com
 * @Date: 2023-12-29 17:05:07
 * @LastEditors: yuanqu1208 yubaolin6@outlook.com
 * @LastEditTime: 2024-04-28 20:22:08
 * @FilePath: /fssc-project-template/fssc-common/fssc-template/src/api/passport-auth/index.ts
 * @Description: passport验证中心接口
 */

import httpRequest, { prefix } from '../request';
import { TOKEN_KEY } from '../../util/const';
import Cookie from 'js-cookie';

/**
 * @description: passport 登录
 * @param {*} data
 * @return {*}
 */
export const login = (data) => {
  return httpRequest.post(`${prefix.passportAuth}/v1/api/login`, data, { headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary8VYeR1hKudK3KEy0'} });
}

/**
 * @description: 退出
 * @return {*}
 */
export const loginOut = () => {
  return httpRequest.post(`${prefix.passportAuth}/v1/api/logout`);
}

/**
 * @description: 获取验证码
 * @return {*}
 */
export const captcha = () => {
  return httpRequest.post(`${prefix.passportAuth}/v1/api/getCaptcha`);
}

/**
 * @description: 获取验证码
 * @return {*}
 */
export const findAdminByToken = (projectKey, config = {}) => {

  return httpRequest.get(`${prefix.passportAuth}/v1/api/findAdminByToken`, { projectKey, token: Cookie.get(TOKEN_KEY) }, config);
}

/**
 * @description: 分页查询用户数据
 * @return {*}
 */
export const adminFindPage = (data) => {
  return httpRequest.post(`${prefix.passportAuth}/v1/api/admin/findPage`, data);
}

/**
 * @description: 查询组织架构树
 * @param {*} data
 * @return {*}
 */
export const getDeptTree = (data?: any) => {
  return httpRequest.get(`${prefix.passportAuth}/v1/api/getDepartmentTree`, data, { cacheFlag: true });
}

/**
 * @description: 修改密码
 * @return {*}
 */
export const changePassword = (data) => {
  return httpRequest.get(`${prefix.passportAuth}/v1/api/changePassword`, data, { header: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryIC9f5B6Oe0z9UbxD'} });
}
